﻿/******************************************************************************
 * 
 * Announce: CSharpKit, Basic algorithms, components and definitions.
 *           Copyright (C) ShenYongchen.
 *           All rights reserved.
 *   Author: 申永辰.郑州 (shenyczz@163.com)
 *  WebSite: http://gitee.com/shenyczz/csharp_csk
 *
 * THIS CODE IS LICENSED UNDER THE MIT LICENSE (MIT).
 * THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF 
 * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
 * IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
 * PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
 * 
******************************************************************************/
using System;
using System.Runtime.InteropServices;

using codes_handle = System.IntPtr;

namespace CSharpKit.Native.ECCODES
{
    // 
    // get and set functions
    // Accessing header and data values
    // 
    partial class eccodes
    {
        /// <summary>
        /// <para>功能: Get the number offset of a key </para>
        /// <para>说明: in a message if several keys of the same name are present, 
        /// the offset of the last one is returned</para>
        /// </summary>
        /// <param name="handle">the handle to get the offset from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="offset">the address of a size_t where the offset will be set </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_offset(const codes_handle* h, const char* key, size_t* offset)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_offset")]
        public static extern int codes_get_offset(codes_handle handle, string key, out int offset);


        /// <summary>
        /// <para>功能: Get the number of coded value from a key </para>
        /// <para>说明: if several keys of the same name are present, the total sum is returned. </para>
        /// </summary>
        /// <param name="handle">the handle to get the offset from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="size">the address of a size_t where the size will be set </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_size(const codes_handle* h, const char* key, size_t* size)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_size")]
        public static extern int codes_get_size(codes_handle handle, string key, int size);

        /// <summary>
        /// <para>功能: Get the length of the string representation of the key</para>
        /// <para>说明: if several keys of the same name are present, the maximum length is returned</para>
        /// </summary>
        /// <param name="handle">the handle to get the offset from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="lentgh">the address of a size_t where the length will be set </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_length(const codes_handle* h, const char* key, size_t* length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_length")]
        public static extern int codes_get_length(codes_handle handle, string key, out int lentgh);

        /// <summary>
        /// <para>功能: Get a long value from a key</para>
        /// <para>说明: if several keys of the same name are present, the last one is returned </para>
        /// </summary>
        /// <param name="handle">the handle to get the data from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="value">the address of a long where the data will be retrieved </param>
        /// <returns>0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_long(const codes_handle* h, const char* key, long* value) <br/>
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_long")]
        public static extern int codes_get_long(codes_handle handle, string key, out long value);


        /// <summary>
        /// <para>功能: Get a double value from a key</para>
        /// <para>说明: if several keys of the same name are present, the last one is returned</para>
        /// </summary>
        /// <param name="handle">the handle to get the data from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="value">the address of a double where the data will be retrieved </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_double(const codes_handle* h, const char* key, double* value)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_double")]
        public static extern int codes_get_double(codes_handle handle, string key, out double value);

        /// <summary>
        /// <para>功能: Get as double the i-th element of the "key" array. </para>
        /// <para>说明: </para>
        /// </summary>
        /// <param name="handle">the handle to get the data from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="i">zero-based index </param>
        /// <param name="value">the address of a double where the data will be retrieved </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_double_element(const codes_handle* h, const char* key, int i, double* value)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_double_element")]
        public static extern int codes_get_double_element(codes_handle handle, string key, int i, out double value);


        /// <summary>
        /// <para>功能: Get as double array the elements of the "key" array whose indexes are listed in the input array i </para>
        /// <para>说明: </para>
        /// </summary>
        /// <param name="handle">the handle to get the data from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="i">zero-based array of indexes </param>
        /// <param name="size">size of the i and value arrays </param>
        /// <param name="values">the double array for the data values </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_double_elements(const codes_handle* h, const char* key, int* i, long size, double* value)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_double_elements")]
        public static extern int codes_get_double_elements(codes_handle handle, in string[] key, in int[] i, long size, out double[] values);

        /// <summary>
        /// <para>功能: Get double array values from a key. </para>
        /// <para>说明: If several keys of the same name are present, the last one is returned</para>
        /// </summary>
        /// <param name="handle">the handle to get the data from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="values">the address of a double array where the data will be retrieved </param>
        /// <param name="length">the address of a size_t that contains allocated length of the double array on input, 
        /// and that contains the actual length of the double array on output </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_double_array(const codes_handle* h, const char* key, double* vals, size_t* length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_double_array")]
        public static extern int codes_get_double_array(codes_handle handle, string key, out double[] values, out int length);


        /// <summary>
        /// <para>功能: Get a string value from a key</para>
        /// <para>说明: if several keys of the same name are present, the last one is returned</para>
        /// </summary>
        /// <param name="handle">the handle to get the data from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="msg">the address of a string where the data will be retrieved </param>
        /// <param name="length">the address of a size_t that contains allocated length of the string on input, 
        /// and that contains the actual length of the string on output </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_string(const codes_handle* h, const char* key, char* mesg, size_t* length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_string")]
        public static extern int codes_get_string(codes_handle handle, string key, out string msg, out int length);


        /// <summary>
        /// <para>功能: Get string array values from a key</para>
        /// <para>说明: If several keys of the same name are present, the last one is returned</para>
        /// </summary>
        /// <param name="handle">the handle to get the data from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="values">the address of a string array where the data will be retrieved </param>
        /// <param name="length">the address of a size_t that contains allocated length of the array on input, 
        /// and that contains the actual length of the array on output </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_string_array(const codes_handle* h, const char* key, char** vals, size_t* length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_string_array")]
        public static extern int codes_get_string_array(codes_handle handle, string key, out string[] values, out int length);

        /// <summary>
        /// <para>功能: Get raw bytes values from a key.</para>
        /// <para>说明: If several keys of the same name are present, the last one is returned. </para>
        /// </summary>
        /// <param name="handle">the handle to get the data from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="values">the address of a byte array where the data will be retrieved </param>
        /// <param name="length">the address of a size_t that contains allocated length of the byte array on input, 
        /// and that contains the actual length of the byte array on output </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_bytes(const codes_handle* h, const char* key, unsigned char* bytes, size_t* length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_bytes")]
        public static extern int codes_get_bytes(codes_handle handle, string key, out byte[] values, out int length);

        /// <summary>
        /// <para>功能: Get long array values from a key. </para>
        /// <para>说明: If several keys of the same name are present, the last one is returned </para>
        /// </summary>
        /// <param name="handle">the handle to get the data from </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="values">the address of a long array where the data will be retrieved </param>
        /// <param name="length">the address of a size_t that contains allocated length of the long array on input, 
        /// and that contains the actual length of the long array on output </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_get_long_array(const codes_handle* h, const char* key, long* vals, size_t* length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_get_long_array")]
        public static extern int codes_get_long_array(codes_handle handle, string key, out long[] values, out int length);

        /// <summary>
        /// <para>功能: Copy the keys belonging to a given namespace from a source handle to a destination handle</para>
        /// <para>说明: </para>
        /// </summary>
        /// <param name="hdest">destination handle </param>
        /// <param name="name">namespace </param>
        /// <param name="hsrc">source handle </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_copy_namespace(codes_handle* dest, const char* name, codes_handle* src)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_copy_namespace")]
        public static extern int codes_copy_namespace(codes_handle hdest, string name, codes_handle hsrc);

        // 
        //========= setting data
        // 

        /// <summary>
        /// <para>功能: Set a long value from a key.</para>
        /// <para>说明: If several keys of the same name are present, the last one is set. </para>
        /// </summary>
        /// <param name="handle">the handle to set the data to </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="value">a long where the data will be read </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_set_long(codes_handle* h, const char* key, long val)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_set_long")]
        public static extern int codes_set_long(codes_handle handle, string key, long value);

        /// <summary>
        /// <para>功能: Set a double value from a key.</para>
        /// <para>说明: If several keys of the same name are present, the last one is set. </para>
        /// </summary>
        /// <param name="handle">the handle to set the data to </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="value">a double where the data will be read </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_set_double(codes_handle* h, const char* key, double val)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_set_double")]
        public static extern int codes_set_double(codes_handle handle, string key, double value);

        /// <summary>
        /// <para>功能: Set a string value from a key.</para>
        /// <para>说明: If several keys of the same name are present, the last one is set</para>
        /// </summary>
        /// <param name="handle">the handle to set the data to </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="msg">the address of a string where the data will be read </param>
        /// <param name="length">the address of a size_t that contains the length of the string on input, 
        ///  and that contains the actual packed length of the string on output</param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_set_string(codes_handle* h, const char* key, const char* mesg, size_t* length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_set_string")]
        public extern static int codes_set_string(codes_handle handle, string key, string msg, int length);


        /// <summary>
        /// <para>功能: Set a bytes array from a key. </para>
        /// <para>说明: If several keys of the same name are present, the last one is set</para>
        /// </summary>
        /// <param name="handle">the handle to set the data to </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="bytes">the address of a byte array where the data will be read </param>
        /// <param name="length">the address of a size_t that contains the length of the byte array on input, 
        /// and that contains the actual packed length of the byte array  on output </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_set_bytes(codes_handle* h, const char* key, const unsigned char* bytes, size_t* length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_set_bytes")]
        public extern static int codes_set_bytes(codes_handle handle, string key, byte[] bytes, int length);

        /// <summary>
        /// <para>功能: Set a double array from a key. </para>
        /// <para>说明: If several keys of the same name are present, the last one is set</para>
        /// </summary>
        /// <param name="handle">the handle to set the data to </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="values">the address of a double array where the data will be read </param>
        /// <param name="length">a size_t that contains the length of the byte array on input </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_set_double_array(codes_handle* h, const char* key, const double* vals, size_t length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_set_double_array")]
        public extern static int codes_set_double_array(codes_handle handle, string key, double[] values, int length);


        /// <summary>
        /// <para>功能: Same as codes_set_double_array but allows setting of READ-ONLY keys like codedValues. </para>
        /// <para>说明: Use with great caution(小心)!! </para>
        /// </summary>
        /// <param name="handle">the handle to set the data to </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="values">the address of a double array where the data will be read </param>
        /// <param name="length">a size_t that contains the length of the byte array on input </param>
        /// <returns> </returns>
        /// <remarks>
        /// 原型: int codes_set_force_double_array(codes_handle* h, const char* key, const double* vals, size_t length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_set_force_double_array")]
        internal extern static int codes_set_force_double_array(codes_handle handle, string key, double[] values, int length);

        /// <summary>
        /// <para>功能: Set a long array from a key. </para>
        /// <para>说明: If several keys of the same name are present, the last one is set</para>
        /// </summary>
        /// <param name="handle">the handle to set the data to </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="values">the address of a long array where the data will be read </param>
        /// <param name="length">a size_t that contains the length of the byte array on input </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_set_long_array(codes_handle* h, const char* key, const long* vals, size_t length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_set_long_array")]
        public static extern int codes_set_long_array(codes_handle handle, string key, long[] values, int length);

        /// <summary>
        /// <para>功能: Set a string array from a key. </para>
        /// <para>说明: If several keys of the same name are present, the last one is set </para>
        /// </summary>
        /// <param name="handle">the handle to set the data to </param>
        /// <param name="key">the key to be searched </param>
        /// <param name="values">the address of a string array where the data will be read </param>
        /// <param name="length">a size_t that contains the length of the byte array on input </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_set_string_array(codes_handle* h, const char* key, const char** vals, size_t length)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_set_string_array")]
        public static extern int codes_set_string_array(codes_handle handle, string key, string[] values, int length);

        // {{END}}
    }


}
